<?php

/**
 * Created by PhpStorm.
 * User: evan
 * Date: 2016/12/22
 * Time: 下午10:28
 */
class Password extends MY_Public_Api_Controller
{
    public function set_password()
    {
        $uid      = (int)$this->input->get_post('uid');
        $mobile   = trim($this->input->get_post('mobile'));
        $code     = trim($this->input->get_post('code'));
        $password = trim($this->input->get_post('password'));


        $this->load->service('user/service_user_password');
        $data = $this->service_user_password->set_password($uid, $mobile, $code, $password);


        $this->json_output($data['data'], $data['status']);
    }



    /**
     * 忘记密码
     */
    public function forgot_password()
    {
        $mobile   = trim($this->input->get_post('mobile'));
        $code     = trim($this->input->get_post('code'));
        $password = trim($this->input->get_post('password'));


        $this->load->service('user/service_user_password');
        $data = $this->service_user_password->forgot_password($mobile, $code, $password);


        $this->json_output($data['data'], $data['status']);
    }


    /**
     * 重置用户密码
     */
    public function reset_password()
    {
        $mobile   = trim($this->input->get_post('mobile'));
        $code     = trim($this->input->get_post('code'));
        $password = trim($this->input->get_post('password'));


        $this->load->service('user/service_user_password');
        $data = $this->service_user_password->reset_password($mobile, $code, $password);


        $this->json_output($data['data'], $data['status']);
    }


    public function modify()
    {
        $mobile       = trim($this->input->get_post('mobile'));
        $old_password = trim($this->input->get_post('old_password'));
        $password     = trim($this->input->get_post('password'));


        $this->load->service('user/service_user_password');
        $data = $this->service_user_password->modify($mobile, $old_password, $password);


        $this->json_output($data['data'], $data['status']);
    }
}